##
## Makefile for Arduino in /home/wild/ARDUINO/lib
## 
## Made by Anthony FOURNIER
## Login   <anthony.fournier@gmx.com>
## 
## Started on  Sat Jul  9 12:29:31 2011 Anthony FOURNIER
## Last update Mon Aug 15 20:03:51 2011 Anthony Fournier
##

LIB      =	core.a

PATHSRC  = 	./src

CPPSRC   =	$(PATHSRC)/HardwareSerial.cpp	\
		$(PATHSRC)/main.cpp		\
		$(PATHSRC)/Print.cpp  		\
		$(PATHSRC)/Tone.cpp  		\
		$(PATHSRC)/WMath.cpp  		\
		$(PATHSRC)/WString.cpp

CCSRC    =	$(PATHSRC)/pins_arduino.c	\
		$(PATHSRC)/wiring_analog.c  	\
		$(PATHSRC)/wiring_digital.c  	\
		$(PATHSRC)/wiring_shift.c	\
		$(PATHSRC)/WInterrupts.c   	\
		$(PATHSRC)/wiring.c         	\
		$(PATHSRC)/wiring_pulse.c

CPPOBJ   = 	$(CPPSRC:.cpp=.o)

COBJ     =	$(CCSRC:.c=.o)

INCLUDE = 	-I./include/

WFLAGS   = 	-W -Wall -Wextra

CCFLAGS  = 	-Os -w -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=22 $(WFLAGS)
CPPFLAGS = 	$(CCFLAGS) -fno-exceptions

RM       =	rm -f

GCC      =	avr-gcc
GPP      =	avr-g++
AR       =     	avr-ar rcsv

# RULES

.cpp.o:
	$(GPP) $(INCLUDE) $(CPPFLAGS) -c $< -o $@

.c.o:
	$(GCC) $(INCLUDE) $(CCFLAGS) -c $< -o $@

all:    $(LIB)

$(LIB): $(CPPOBJ) $(COBJ)
	$(AR) $(LIB) $(CPPOBJ) $(COBJ)

clean:
	$(RM) $(COBJ)
	$(RM) $(CPPOBJ)

fclean: clean
	$(RM) $(LIB)

re:     fclean all
